//
//  CSSettlementViewController.m
//  ZSYH
//
//  Created by 主事丫环 on 2019/4/11.
//  Copyright © 2019 魏堰青. All rights reserved.
//

#import "CSSettlementViewController.h"
//#import "CSCbankCardListModel.h"
#import "CSPersonModel.h"
#import "MyacontViewController.h"
#import "BSQJSViewController.h"
#import "BSQJSModel.h"

@interface CSSettlementViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *cardImage;
@property (weak, nonatomic) IBOutlet UILabel *cardName;
@property (weak, nonatomic) IBOutlet UIImageView *bgimage;

@property (weak, nonatomic) IBOutlet UILabel *moneyLB;
@property (weak, nonatomic) IBOutlet UIButton *gobut;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *weithcon;
@property (weak, nonatomic) IBOutlet UILabel *serviceChargeL;
@property (weak, nonatomic) IBOutlet UILabel *actualProfitL;

@property(nonatomic,strong)UIView *bgView;
@property(nonatomic,strong)CSPersonModel *model;
@property(nonatomic,strong)BSQJSModel *sqjsmodel;

@end

@implementation CSSettlementViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    if (_model) {
        [self requestDare];
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"申请结算";
    self.sqjsmodel = [[BSQJSModel alloc]init];

    [self.leftbutton setImage:imgname(@"left_icon") forState:(UIControlStateNormal)];

    [self.bgimage shadowshadowOpacity:0.2 borderWidth:0 borderColor:[UIColor colorWithHexString:@"#FFFFFF"] erRadius:8 shadowColor:[UIColor colorWithHexString:@"#000000"] shadowRadius:5 shadowOffset:CGSizeMake(0, 1)];
    
    self.model = [[CSPersonModel alloc]init];
  
    [self requestDare];
    // Do any additional setup after loading the view from its nib.
}
-(void)requestDare{
    kWeakSelf;
   
    
    
    
    [NetWorkTool POST:CcentenInfo param:nil success:^(id dic) {
        
        [self.model setValuesForKeysWithDictionary:[dic objectForKey:@"data"]];
  
        
        if (strIsEmpty(weakSelf.model.wx_image_url)  && strIsEmpty(weakSelf.model.alipay_image_url)) {
            weakSelf.weithcon.constant = 0.01;
            weakSelf.cardImage.image = imgname(@"");
            weakSelf.gobut.hidden = NO;

            
        }else{
            weakSelf.gobut.hidden = YES;
            weakSelf.weithcon.constant = 26;

            if ( [weakSelf.model.type integerValue] == 1) {
             //微信
                [weakSelf.cardImage sd_setImageWithURL:[NSURL URLWithString:weakSelf.model.wx_image_url] placeholderImage:defaultImg];
                weakSelf.cardName.text =weakSelf.model.wx_name;
            }else if ([weakSelf.model.type integerValue] == 2){
               //zhifubao
                [weakSelf.cardImage sd_setImageWithURL:[NSURL URLWithString:weakSelf.model.alipay_image_url] placeholderImage:defaultImg];
                weakSelf.cardName.text =weakSelf.model.alipay_name;

                
            }
            
            
        }
        
        
    } other:^(id dic) {
        
    } fail:^(NSError *error) {
        
    } needUser:YES];
    
    
    [NetWorkTool POST:BMonygetSetMoney param:nil success:^(id dic) {
        KMyLog(@"dfasfdasfadsfads%@",dic);
        [weakSelf.sqjsmodel setValuesForKeysWithDictionary:[dic objectForKey:@"data"]];
        
        weakSelf.moneyLB.text = [NSString stringWithFormat:@"¥%@",weakSelf.sqjsmodel.setMoney];
        weakSelf.serviceChargeL.text = [NSString stringWithFormat:@"¥%@",weakSelf.sqjsmodel.sxf];
        weakSelf.actualProfitL.text = [NSString stringWithFormat:@"¥%@",weakSelf.sqjsmodel.actualMoney];
        
    } other:^(id dic) {
        ShowToastWithText(dic[@"msg"]);
    } fail:^(NSError *error) {
        
    } needUser:YES];
    
}







/**
 //阴影削圆角
 
 @param pacity  阴影透明度
 @param Width 边框宽度
 @param color 边框颜色
 @param cornerRadius 圆角大小
 @param shadowColo 阴影颜色
 @param Radius 阴影扩散的范围控制
 @param SizeMake 阴影的范围
 */
//-(void)shadowshadowOpacity:(CGFloat)pacity borderWidth:(CGFloat)Width borderColor:(UIColor *)color erRadius:(CGFloat)cornerRadius shadowColor:(UIColor *)shadowColo shadowRadius:(CGFloat)Radius shadowOffset:(CGSize)SizeMake;
- (IBAction)seletcotIdcareAction:(UIButton *)sender {
    [self qubangding];
}
- (IBAction)gobuilding:(UIButton *)sender {
    [self qubangding];

}
-(void)qubangding{
    
    MyacontViewController *mosdfj = [[MyacontViewController alloc]init];
    mosdfj.model = _model;
    [self.navigationController pushViewController:mosdfj animated:YES];
    
}
- (IBAction)goJIesuan:(UIButton *)sender {
    
    kWeakSelf;
    if (strIsEmpty(weakSelf.model.wx_image_url)  && strIsEmpty(weakSelf.model.alipay_image_url)) {
        ShowToastWithText(@"请先设置账户");
        
        return;
    }
    if ([_sqjsmodel.setMoney integerValue ] == 0) {
        ShowToastWithText(@"您的可提现金额为0");
        return;

    }
    
    sender.userInteractionEnabled = NO;
    
    [NetWorkTool POST:BeMyShopdoAppSet param:nil success:^(id dic) {
        ShowToastWithText(@"申请结算成功成功");
        
        [weakSelf.navigationController popViewControllerAnimated:YES];
        
    } other:^(id dic) {
        ShowToastWithText(dic[@"msg"]);
    } fail:^(NSError *error) {
        
    } needUser:YES];
    
    
    
    
    
//    //去结算
    
//    if (!_mymodel) {
//        ShowToastWithText(@"请选择银行卡");
//        return;
//    }
//
//    if ([_moneyLB.text isEqualToString:@"￥00.00"]) {
//        ShowToastWithText(@"您没有可提现金额");
//        return;
//    }
//
//    NSMutableDictionary *param = [NSMutableDictionary dictionaryWithCapacity:1];
//    param[@"bankCard"] = _mymodel.bank_card;
//    [NetWorkTool POST:tixianAccont param:param success:^(id dic) {
////        ShowToastWithText(@"提交成功");
//
//        [[UIApplication sharedApplication].keyWindow addSubview:self.bgView];
//    } other:^(id dic) {
//
//    } fail:^(NSError *error) {
//
//    } needUser:YES];
    
    
}


@end
